package cn.tsmchina.one.util;

import java.net.URLEncoder;

import javax.servlet.http.HttpServletRequest;

public final  class Return
{
	public static String redirect(HttpServletRequest request)
	{
		try
		{
			String returnUrl = URLEncoder.encode((String)request.getAttribute("return"),"utf-8");
			String msgType = (String) request.getAttribute("msgType");
			String msg =URLEncoder.encode((String) request.getAttribute("msg"), "utf-8");
			return "redirect:/msg?msgType="+msgType+"&msg="+msg+"&return="+returnUrl;
		} catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}
	
	public static String encode(String encode)
	{
		try
		{
			return URLEncoder.encode(encode, "utf-8");
		} catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}
}
